// 哈希表
class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
        unordered_map<int, int> hash;   // <nums[i], i>
        for(int i = 0; i < nums.size(); i++)
        {
            int x = target - nums[i];
            if(hash.count(x))
                return {hash[x], i};
            hash[nums[i]] = i;
        }

        return {-1, -1};
    }
};

//########################################################
class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
        vector<int> vec(2, 0);
        // 遍历数组
        for(int i = 0; i < nums.size(); i++)
        {
            for(int j = i + 1; j < nums.size(); j++)
            {
                if(nums[i] + nums[j] == target)
                {
                    vec[0] = i;
                    vec[1] = j;
                }
            }
        }
    
        return vec;
    }
};